<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <button onclick="add(a,b)">加</button>
    <button onclick="sub(a,b)">减</button>
    <button onclick="mul(a,b)">乘</button>
    <button onclick="div(a,b)">除</button>

    <script>
        var a = window.prompt("请输入第一个数", "a");
        var b = window.prompt("请输入第二数", "b");

        function add(a, b) {
            alert("a和b的和是" + (parseInt(a) + parseInt(b)));

        }

        function sub(a, b) {

            alert("a和b的差是" + (a - b));

        }

        function mul(a, b) {

            alert("a和b的积是" + (a * b));

        }

        function div(a, b) {

            alert("a和b的商是" + (a / b));

        }
    </script>

</body>

</html>